Use isatty instead of stat/S_ISCHR to determine "serialness".
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 11 Aug 2003 16:30:55 +0000 (16:30 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 11 Aug 2003 16:30:55 +0000 (16:30 +0000)
gpsbabel/magproto.c

index 888c47ff071056b89c0872f0a848f7ee808bedf0..9e68eb590fccc9271ce4138b64f3827de32d5459 100644 (file)
@@ -22,7 +22,6 @@
 #include <ctype.h>
 #include <time.h>
 #include <errno.h>
-#include <sys/stat.h>
 
 #include "defs.h"
 #include "magellan.h"
@@ -631,7 +630,6 @@ static void
 terminit(const char *portname)
 {
        struct termios new_tio;
-       struct stat sbuf;
 
         magfile_in = fopen(portname, "rb");
 
@@ -640,8 +638,7 @@ terminit(const char *portname)
                         portname, strerror(errno));
         }
 
-       fstat(fileno(magfile_in), &sbuf);
-       is_file = S_ISREG(sbuf.st_mode);
+       is_file = !isatty(fileno(magfile_in));
        if (is_file) {
                icon_mapping = map330_icon_table;
                mag_cleanse = m330_cleanse;
@@ -757,14 +754,12 @@ mag_wr_init(const char *portname, const char *args)
                is_file = 1;
        }
 #else
-       struct stat sbuf;
        magfile_out = fopen(portname, "w+b");
        if (!magfile_out) {
                fatal(MYNAME ": '%s' cannot be opened for writing.\n",
                                portname);
        }
-       fstat(fileno(magfile_out), &sbuf);
-       is_file = S_ISREG(sbuf.st_mode);
+       is_file = !isatty(fileno(magfile_out));
 #endif
 
        if (!mkshort_handle) {